//判断cook是否登录
function ck(key){
    var ckl=document.cookie
    console.log(ckl)
    var arr=ckl.split('; ')
    for(var i=0;i<arr.length;i++){
        var zhong1=arr[i].split('=')
        if(zhong1[0]==key){
             var deng1=document.getElementById('deng1')
             deng1.innerHTML="欢迎"+zhong1[1]
        }
    }
}
ck('name')
function lun1(){
	var som=0
	dsq1=setInterval(()=>{
	som++
	if(som>4){
		$('.toulun').css('top',-35)
		som=2
	}
	$('.toulun').animate({top:-som*35},500)
},2000)
}
lun1()
var a=0
var b=0
//创建运动函数
function yun(){
	a++
	if(a>4){
		a=0
	}
	$('.lunbox li').eq(a).css('left','100%')
	$('.lunbox li').eq(a).animate({left:0},500)
	$('.lunbox li').eq(b).animate({left:'-100%'},500)
	$('.lun>ul li').eq(b).prop('class','lun_yan')
	$('.lun>ul li').eq(b).siblings().removeClass('lun_yan')
	b=a
}
yun()
setInterval(yun,3000)
function yun2(){
	a--
	if(a<0){
		a=4
	}
	b=a
	$('.lunbox li').eq(a).css('left','-100%')
	$('.lunbox li').eq(a).animate({left:0},500)
	$('.lunbox li').eq(b).animate({left:'100%'},500)
	$('.lun>ul li').eq(b).prop('class','lun_yan')
	$('.lun>ul li').eq(b).siblings().removeClass('lun_yan')
	
}
$('.butlf').click(yun2)
$('.butri').click(yun)

//导航
var dao1=document.querySelector('.daobox')
window.onscroll=function(){
	let gun1=window.pageYOffset
	if(gun1>100){
		dao1.style.position='fixed'
		dao1.style.borderBottom='3px solid #000'
		dao1.style.zIndex='5'
	}else{
		dao1.style.position=''
		dao1.style.border=''
		dao1.style.zIndex=''
	}
}
//鼠标移入事件
var $xian1=$('.shou12_yi>:nth-child(2)')
var yi1=document.querySelector('.shou12>:nth-child(1)')
var yi2=document.querySelector('.shou12>:nth-child(2)')
yi1.onmousemove=function(){
	$('.shou12_yi>:nth-child(1)').css({display:'block',zIndex:8})
}
yi1.onmouseout=function(){
	$('.shou12_yi>:nth-child(1)').css({display:'none'})
}

// 移入2
yi2.onmousemove=function(){
	$('.shou12_yi>:nth-child(2)').css({display:'block'})
}
yi2.onmouseout=function(){

		$('.shou12_yi>:nth-child(2)').css({display:'none'})

}
var yi22=document.querySelector('.shou12_yi>:nth-child(2)')
yi22.onmouseenter=function(){
	yi22.style.display='block'
}
yi22.onmouseleave=function(){
	yi22.style.display='none'
}

//产品的点击显示
var zhan1=document.querySelector('.zhan')
zhan1.onclick=function(e){
	var e=e || window.event
	var dian=e.srcElement || e.strget
	if(dian.innerHTML=='香水'){
		$('.zhan>:nth-child(3)').css('display','block')
		$('.zhan>:nth-child(3)').siblings().css('display','none').first().css('display','block')
		$('.zhan_tou>ul>:nth-child(2)').prop('class','zhan_yan').siblings().removeClass('zhan_yan')
	}
	if(dian.innerHTML=='护肤'){
		$('.zhan>:nth-child(4)').css('display','block')
		$('.zhan>:nth-child(4)').siblings().css('display','none').first().css('display','block')
		$('.zhan_tou>ul>:nth-child(3)').prop('class','zhan_yan').siblings().removeClass('zhan_yan')
	}
	if(dian.innerHTML=='礼盒'){
		$('.zhan>:nth-child(5)').css('display','block')
		$('.zhan>:nth-child(5)').siblings().css('display','none').first().css('display','block')
		$('.zhan_tou>ul>:nth-child(4)').prop('class','zhan_yan').siblings().removeClass('zhan_yan')
	}
	if(dian.innerHTML=='彩妆'){
		$('.zhan>:nth-child(2)').css('display','block')
		$('.zhan>:nth-child(2)').siblings().css('display','none').first().css('display','block')
		$('.zhan_tou>ul>:nth-child(1)').prop('class','zhan_yan').siblings().removeClass('zhan_yan')
	}

}
//全局点击事件
var boy2=document.body
boy2.onclick=function(e){
	var e=e ||window.event
	var dian=e.target || e.srcElement
	if(dian.innerHTML=='创建账户'){
		window.location.href= "./zhu.html"
	}
}
